package com.ruoyi.common.core.mybatis;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.StrUtils;

import java.util.List;

/**
 * @author : hcl
 * @Date : 2023/9/8 10:17
 */
public class Query<T> extends QueryWrapper<T> {
    private static final long serialVersionUID = -4951837961829511738L;

    public Query<T> selectColumn(String... columns) {
        super.select(columns);
        return this;
    }

    public Query<T> teamId(Long teamId) {
        super.eq("team_id", teamId);
        return this;
    }

    public Query<T> wxId(String wxId) {
        super.eq("wx_id", wxId);
        return this;
    }

    public Query<T> id(Long id) {
        super.eq("id", id);
        return this;
    }

    public Query<T> isDelete(Boolean delete) {
        if (delete != null) {
            super.eq("is_delete", delete);
        }
        return this;
    }

    public Query<T> chatId(Long chatId) {
        super.eq("chat_id", chatId);
        return this;
    }

    /**
     * val 不为空时 添加
     */
    public Query<T> nonEq(String column, String val) {
        if (StrUtils.isNotEmpty(val)) {
            super.eq(column, val);
        }
        return this;
    }

    /**
     * val 不为空时 添加
     */
    public Query<T> nonLike(String column, String val) {
        if (StrUtils.isNotEmpty(val)) {
            super.like(column, val);
        }
        return this;
    }

    @Override
    public Query<T> eq(String column, Object val) {
        super.eq(column, val);
        return this;
    }

    @Override
    public Query<T> between(String column, Object val1, Object val2) {
        super.between(column, val1, val2);
        return this;
    }

    @Override
    public Query<T> ge(String column, Object val) {
        super.ge(column, val);
        return this;
    }
}
